home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #3 / Amiga Plus CD - 1999 - No. 3.iso / System / delitracker_ii / developer / examples / testplayer.s < prev   
Text File  |  1995-04-28  |  14KB  |  547 lines

  1. **
  2. **    Testplayer.s
  3. **
  4. **    A sample player that visually reports DeliTracker's actions
  5. **    within external players.
  6. **
  7. **    Use the source as a skeleton model for your own players.
  8. **    Refer to the sample sources for additional information.
  9. **
  10. **    Once assembled, load this player into DeliTracker, and try
  11. **    playing the file 'testmodule'.  It is only a textfile with
  12. **    the word "TEST" at the beginning.  Notice now that
  13. **    DeliTracker's actions on the module are visible.  This should
  14. **    aid you in your coding sequences.
  15. **
  16. **    Original source by Peter Kunath and Frank Riffel of Delirium.
  17. **
  18. **    English, comments, and general banter by Kevin Dackiw.
  19. **
  20. **    Have any problems/concerns/ideas?  Feel free to contact the
  21. **    authors:
  22. **
  23. **    Frank Riffel
  24. **    Merkstr. 27
  25. **    82405 Wessobrunn
  26. **    Germany
  27. **
  28.  
  29.     incdir    "includes:"
  30.     include    "dos/dos.i"
  31.     include    "intuition/intuition.i"
  32.     include    "misc/DevpacMacros.i"
  33.     include    "misc/DeliPlayer.i"
  34.  
  35. ;
  36. ;
  37.     SECTION Player,Code
  38. ;
  39. ;
  40.  
  41.     PLAYERHEADER PlayerTagArray            ; define start of header
  42.  
  43.     dc.b '$VER: TestPlayer 2.01 (15 Apr 94)',0    ; for OS 2.0 version command
  44.     even
  45.  
  46. PlayerTagArray
  47.     dc.l    DTP_RequestDTVersion,16            ; define all the tags
  48.     dc.l    DTP_PlayerVersion,02<<16+01
  49.     dc.l    DTP_PlayerName,PName            ; for the player
  50.     dc.l    DTP_Creator,CName
  51.     dc.l    DTP_DeliBase,delibase
  52.     dc.l    DTP_Check1,Chk                ; omit any unused
  53.     dc.l    DTP_Config,Config            ; functions as
  54.     dc.l    DTP_UserConfig,UserConfig        ; needed!
  55.     dc.l    DTP_SubSongRange,SubSong
  56.     dc.l    DTP_Process,Begin
  57.     dc.l    DTP_Priority,0
  58.     dc.l    DTP_StackSize,4096
  59.     dc.l    DTP_MsgPort,DeliPort
  60.     dc.l    DTP_InitPlayer,InitPlay
  61.     dc.l    DTP_EndPlayer,EndPlay
  62.     dc.l    DTP_InitSound,InitSnd
  63.     dc.l    DTP_EndSound,EndSnd
  64.     dc.l    DTP_StartInt,StartSnd
  65.     dc.l    DTP_StopInt,StopSnd
  66.     dc.l    DTP_Volume,Volume
  67.     dc.l    DTP_Balance,Balance
  68.     dc.l    DTP_Faster,Faster
  69.     dc.l    DTP_Slower,Slower
  70.     dc.l    DTP_PrevPatt,PrevPatt
  71.     dc.l    DTP_NextPatt,NextPatt
  72.     dc.l    DTP_PrevSong,PrevSub
  73.     dc.l    DTP_NextSong,NextSub
  74.     dc.l    TAG_DONE                ; signify end of tags
  75.  
  76. *-----------------------------------------------------------------------*
  77. ;
  78. ; Playername / creatorname
  79. ;
  80. *-----------------------------------------------------------------------*
  81.  
  82. PName    dc.b    'TestPlayer',0
  83. CName    dc.b    'Written by Delirium for Testpurposes',0
  84.     even
  85.  
  86. *-----------------------------------------------------------------------*
  87. ;
  88. ; Player Task
  89. ;
  90. *-----------------------------------------------------------------------*
  91.  
  92. Begin
  93.     move.l    delibase,a5            ; get DeliBase
  94.     move.l    dtg_DOSBase(a5),_DOSBase
  95.     move.l    dtg_IntuitionBase(a5),_IntuitionBase
  96.  
  97.     bsr    About                ; display About-Requester
  98.  
  99.     move.l    #ConsoleName,d1
  100.     move.l    #MODE_NEWFILE,d2
  101.     CALLDOS Open
  102.     move.l    d0,d1
  103.     beq    Quit                ; Error
  104.     CALLDOS SelectOutput
  105.     move.l    d0,_OldOutput
  106.  
  107.     lea    StartTxt0,a0            ; fetch text
  108.     bsr    WriteInfoTxt            ; output
  109.  
  110. ;--------------------------------------------------------------------------
  111. ;
  112. ; Mainloop
  113.  
  114. MainLoop
  115.     move.l    #SIGBREAKF_CTRL_C,d0        ; quit on CTRL-C
  116.  
  117.     move.l    DeliPort,a0
  118.     move.b    MP_SIGBIT(a0),d1        ; DeliMask holen
  119.     bset.l    d1,d0
  120.  
  121.     CALLEXEC Wait                ; Schlaf gut
  122.  
  123.     btst.l    #SIGBREAKB_CTRL_C,d0        ; CTRL-C signal ?
  124.     beq.s    DeliCollect            ; nope !
  125.     bsr    Exit                ; suicide :)
  126.  
  127. DeliCollect                    ; collect DeliTracker msg's
  128.     move.l    DeliPort,a0
  129.     CALLEXEC GetMsg
  130.     tst.l    d0                ; Msg da ?
  131.     beq.s    CollectDone            ; Nein !
  132.     move.l    d0,-(sp)            ; store ^Msg
  133.     move.l    d0,a0
  134.     move.l    DTMN_Function(a0),a0        ; get CMD
  135.     jsr    (a0)                ; Befehl ausführen
  136.     move.l    (sp)+,a1            ; restore ^Msg
  137.     move.l    d0,DTMN_Result(a1)        ; set Result
  138.     CALLEXEC ReplyMsg            ; return to sender
  139.     bra.s    DeliCollect
  140.  
  141. CollectDone
  142.     tst.w    QuitFlag            ; schon Ende ?
  143.     bne    MainLoop            ; noch nicht !
  144.  
  145. ;--------------------------------------------------------------------------
  146. ;
  147. ; quit Player
  148.  
  149. Cleanup
  150.     lea    QuitTxt0,a0            ; fetch text
  151.     bra    WriteInfoTxt            ; output
  152.  
  153.     move.l    _OldOutput,d1
  154.     CALLDOS SelectOutput
  155.     move.l    d0,d1
  156.     CALLDOS Close
  157. Quit
  158.     rts
  159.  
  160.  
  161. ;--------------------------------------------------------------------------
  162. ;
  163. ; End Player
  164.  
  165. Exit
  166.     clr.w    QuitFlag            ; quit Player
  167.     rts
  168.  
  169.  
  170. ;--------------------------------------------------------------------------
  171. ;
  172. ; About Gesülze
  173.  
  174. About
  175.     sub.l    a0,a0
  176.     lea    AboutReqStruct,a1        ; EasyStruct
  177.     sub.l    a2,a2
  178.     sub.l    a3,a3
  179.     CALLINT    EasyRequestArgs
  180.     rts
  181.  
  182.  
  183. *-----------------------------------------------------------------------*
  184. ;
  185. ; Check if the module is a TestPlayer-Module (THIS ROUTINE MUST EXIST!!!)
  186. ;
  187. *-----------------------------------------------------------------------*
  188.  
  189. Chk
  190.     move.l    delibase,a0            ; ^DeliBase
  191.     move.l    dtg_ChkData(a0),a0        ; get module base from DT
  192.     moveq    #0,d0                ; clear register
  193.     cmpi.l    #'TEST',(a0)            ; supported type ?
  194.     sne    d0                ; no - signal false
  195.     rts                    ; leave
  196.  
  197.  
  198. *-----------------------------------------------------------------------*
  199. ;
  200. ; Initialize the player
  201. ;
  202. *-----------------------------------------------------------------------*
  203.  
  204. InitPlay
  205.     lea    InitTxt1,a0            ; fetch text
  206.     bsr    WriteInfoTxt            ; output
  207.     moveq    #0,d0                ; no error
  208.     rts
  209.  
  210.  
  211. *-----------------------------------------------------------------------*
  212. ;
  213. ; Clean up the player
  214. ;
  215. *-----------------------------------------------------------------------*
  216.  
  217. EndPlay
  218.     lea    EndTxt1,a0            ; fetch text
  219.     bra    WriteInfoTxt            ; output
  220.  
  221.  
  222. *-----------------------------------------------------------------------*
  223. ;
  224. ; Initialize the module
  225. ;
  226. *-----------------------------------------------------------------------*
  227.  
  228. InitSnd
  229.     lea    InitTxt2,a0            ; fetch text
  230.     bra    WriteInfoTxt            ; output
  231.  
  232.  
  233. *-----------------------------------------------------------------------*
  234. ;
  235. ; End sound
  236. ;
  237. *-----------------------------------------------------------------------*
  238.  
  239. EndSnd
  240.     lea    EndTxt2,a0            ; fetch text
  241.     bra    WriteInfoTxt            ; output
  242.  
  243.  
  244. *-----------------------------------------------------------------------*
  245. ;
  246. ; Start interrupts
  247. ;
  248. *-----------------------------------------------------------------------*
  249.  
  250. StartSnd
  251.     lea    StartTxt,a0            ; fetch text
  252.     bra    WriteInfoTxt            ; output
  253.  
  254.  
  255. *-----------------------------------------------------------------------*
  256. ;
  257. ; Start interrupts
  258. ;
  259. *-----------------------------------------------------------------------*
  260.  
  261. StopSnd
  262.     lea    StopTxt,a0            ; fetch text
  263.     bra    WriteInfoTxt            ; output
  264.  
  265.  
  266. *-----------------------------------------------------------------------*
  267. ;
  268. ; IMPORTANT NOTE:
  269. ;    There is a BIG difference between the »Config« and the
  270. ;    »UserConfig« Routine !!! The Config routine is immediately
  271. ;    called after that the Player is loaded. It is used to
  272. ;    configure player (e.g. load config file and set pathes)!
  273. ;    The UserConfig routine is only called if the User selects
  274. ;    the player in the PrefWindow and presses the Config Player
  275. ;    GADGET. This routine is thought as a method of getting
  276. ;    informations (playerspecific preferences) from the user
  277. ;    (e.g. pathes for instruments or maximum memory usage).
  278. ;    The difference between Config and InitPlayer is that
  279. ;    Config is called ONCE the player is loaded and that
  280. ;    InitPlayer is called every time a module is played.
  281. ;
  282. *-----------------------------------------------------------------------*
  283. ;
  284. ; get/set playerspecific preferences (configuration routines)
  285. ;
  286. *-----------------------------------------------------------------------*
  287.  
  288. UserConfig
  289.     lea    InfoTxt1,a0            ; fetch text
  290.     bra    WriteInfoTxt            ; output
  291.  
  292. Config
  293.     lea    InfoTxt2,a0            ; fetch text
  294.     bsr    WriteInfoTxt            ; output
  295.     moveq    #0,d0                ; no error
  296.     rts
  297.  
  298.  
  299. *-----------------------------------------------------------------------*
  300. ;
  301. ; Patterncontrol
  302. ;
  303. *-----------------------------------------------------------------------*
  304.  
  305. NextPatt
  306.     lea    InfoTxt3,a0            ; fetch text
  307.     bra    WriteInfoTxt            ; output
  308.  
  309. PrevPatt
  310.     lea    InfoTxt4,a0            ; fetch text
  311.     bra    WriteInfoTxt            ; output
  312.  
  313.  
  314. *-----------------------------------------------------------------------*
  315. ;
  316. ; Subsongcontrol
  317. ;
  318. *-----------------------------------------------------------------------*
  319.  
  320. SubSong
  321.     lea    InfoTxt9,a0            ; fetch text
  322.     bra    WriteInfoTxt            ; output
  323.  
  324. NextSub
  325.     lea    InfoTxt5,a0            ; fetch text
  326.     bra    WriteInfoTxt            ; output
  327.  
  328. PrevSub
  329.     lea    InfoTxt6,a0            ; fetch text
  330.     bra    WriteInfoTxt            ; output
  331.  
  332.  
  333. *-----------------------------------------------------------------------*
  334. ;
  335. ; Speedcontrol
  336. ;
  337. *-----------------------------------------------------------------------*
  338.  
  339. Faster
  340.     lea    InfoTxt7,a0            ; fetch text
  341.     bra    WriteInfoTxt            ; output
  342.  
  343. Slower
  344.     lea    InfoTxt8,a0            ; fetch text
  345.     bra    WriteInfoTxt            ; output
  346.  
  347.  
  348. *-----------------------------------------------------------------------*
  349. ;
  350. ; Volume & Balance Control
  351. ;
  352. *-----------------------------------------------------------------------*
  353.  
  354. Volume
  355.     lea    InfoTxt10,a0            ; fetch text
  356.     bra    WriteInfoTxt            ; output
  357.  
  358. Balance
  359.     lea    InfoTxt11,a0            ; fetch text
  360.     bra    WriteInfoTxt            ; output
  361.  
  362.  
  363. *-----------------------------------------------------------------------*
  364. ;
  365. ; Subroutines
  366. ;
  367. *-----------------------------------------------------------------------*
  368.  
  369. WriteInfoTxt
  370.     move.l    a0,d1
  371.     CALLDOS PutStr
  372.     rts
  373.  
  374.  
  375. *-----------------------------------------------------------------------*
  376.  
  377. ;
  378. ;
  379.     SECTION PlayerDatas,Data
  380. ;
  381. ;
  382.  
  383. delibase:    dc.l 0
  384. DeliPort:    dc.l 0
  385.  
  386. QuitFlag:    dc.w -1                ; running
  387.  
  388. _DOSBase:    dc.l 0
  389. _IntuitionBase:    dc.l 0
  390.  
  391. _OldOutput:    dc.l 0
  392.  
  393.  
  394. *-----------------------------------------------------------------------*
  395. ;
  396. ; Various Texts
  397. ;
  398. *-----------------------------------------------------------------------*
  399.  
  400.  
  401. AboutReqStruct:
  402.     dc.l    EasyStruct_SIZEOF        ; size
  403.     dc.l    0                ; Flags
  404.     dc.l    PName                ; Title
  405.     dc.l    AboutText            ; TextFormat
  406.     dc.l    OkText                ; GadgetFormat
  407.  
  408.  
  409. *-----------------------------------------------------------------------*
  410. ;
  411. ; Various Texts
  412. ;
  413. *-----------------------------------------------------------------------*
  414.  
  415. AboutText    dc.b "           TestPlayer",10
  416.         dc.b "© 1994 by Delirium Softdesign",10
  417.         dc.b 10
  418.         dc.b "An example player that visually",10
  419.         dc.b "reports DeliTracker's actions",10
  420.         dc.b "within external players.",10
  421.         dc.b "The player is running as separte",10
  422.         dc.b "process. Usually this is *not*",10
  423.         dc.b "required.",0
  424.  
  425. OkText        dc.b    '  OK  ',0
  426.  
  427. ConsoleName    dc.b 'CON:20/20/600/160/TestPlayer_Debug',0
  428.  
  429. StartTxt0
  430.     dc.b    27,"[1m",'Player process started.',27,"[0m",10
  431.     dc.b    'Use CTRL-C or the remove function in the playerwindow',10
  432.     dc.b    'to terminate',10
  433.     dc.b    10,0
  434.  
  435. QuitTxt0
  436.     dc.b    27,"[1m",'Player process terminated.',27,"[0m",10
  437.     dc.b    10,0
  438.  
  439. InitTxt1
  440.     dc.b    27,"[1m",'InitPlayer routine called.',27,"[0m",10
  441.     dc.b    'This routine is called every time a new module is loaded.',10
  442.     dc.b    'The audiochannels should be allocated here, and any',10
  443.     dc.b    'player specific initialization should be performed.',10
  444.     dc.b    10,0
  445.  
  446. EndTxt1
  447.     dc.b    27,"[1m",'EndPlayer routine called.',27,"[0m",10
  448.     dc.b    'This routine is called every time a module is killed',10
  449.     dc.b    '(removed from memory).  Player specific cleanup routines',10
  450.     dc.b    'are performed here, and the audiochannels should be',10
  451.     dc.b    'released at this point.',10
  452.     dc.b    10,0
  453.  
  454. InitTxt2
  455.     dc.b    27,"[1m",'InitSound routine called.',27,"[0m",10
  456.     dc.b    'This routine handles the initialization of the module.',10
  457.     dc.b    10,0
  458.  
  459. EndTxt2
  460.     dc.b    27,"[1m",'EndSound routine called.',27,"[0m",10
  461.     dc.b    'This routine clears the audioregisters.',10
  462.     dc.b    10,0
  463.  
  464. StartTxt
  465.     dc.b    27,"[1m",'StartSound routine called.',27,"[0m",10
  466.     dc.b    'This code must start the sound interrupts.',10
  467.     dc.b    'If you use the internal DeliTracker routines, you must',10
  468.     dc.b    'omit this entry from the TagArray.',10
  469.     dc.b    10,0
  470.  
  471. StopTxt
  472.     dc.b    27,"[1m",'StopSound routine called.',27,"[0m",10
  473.     dc.b    'This code must stop the sound interrupts.',10
  474.     dc.b    'If you use the internal DeliTracker routines, you must',10
  475.     dc.b    'omit this entry from the TagArray.',10
  476.     dc.b    10,0
  477.  
  478. InfoTxt1
  479.     dc.b    27,"[1m",'UserConfig routine called.',27,"[0m",10
  480.     dc.b    'This routine is for the use of advanced players.',10
  481.     dc.b    'For example, if your player needs access to a directory',10
  482.     dc.b    'of instruments, this routine could prompt the user with',10
  483.     dc.b    'a requester for the path to the instruments.  Additionally',10
  484.     dc.b    'the path could then be saved in a custom config file, such',10
  485.     dc.b    'as PROGDIR:DeliConfig/TestPlayer.prefs.  Any future runs of the',10
  486.     dc.b    'player would only then have to fetch the path from its config file.',10
  487.     dc.b    'This custom config file must be accessed from the Config routine.',10
  488.     dc.b    10,0
  489.  
  490. InfoTxt2
  491.     dc.b    27,"[1m",'ConfigPlayer routine called.',27,"[0m",10
  492.     dc.b    'This routine is entered after the player is loaded.',10
  493.     dc.b    'At this point you may load a custom config file to fetch',10
  494.     dc.b    'such things as a default instrument path, and the like.',10
  495.     dc.b    10,0
  496.  
  497. InfoTxt3
  498.     dc.b    27,"[1m",'NextPattern routine called.',27,"[0m",10
  499.     dc.b    'This routine skips ahead one pattern in the module.',10
  500.     dc.b    10,0
  501.  
  502. InfoTxt4
  503.     dc.b    27,"[1m",'PrevPattern routine called.',27,"[0m",10
  504.     dc.b    'This routine skips back one pattern in the module.',10
  505.     dc.b    10,0
  506.  
  507. InfoTxt5
  508.     dc.b    27,"[1m",'NextSubsong routine called.',27,"[0m",10
  509.     dc.b    'This routine jumps to the next subsong (if supported).',10
  510.     dc.b    10,0
  511.  
  512. InfoTxt6
  513.     dc.b    27,"[1m",'PrevSubsong routine called.',27,"[0m",10
  514.     dc.b    'This routine jumps to the previous subsong (if supported).',10
  515.     dc.b    10,0
  516.  
  517. InfoTxt7
  518.     dc.b    27,"[1m",'PlayFaster routine called.',27,"[0m",10
  519.     dc.b    'This routine increases the playspeed.',10
  520.     dc.b    10,0
  521.  
  522. InfoTxt8
  523.     dc.b    27,"[1m",'PlaySlower routine called.',27,"[0m",10
  524.     dc.b    'This routine decreases the playspeed.',10
  525.     dc.b    10,0
  526.  
  527. InfoTxt9
  528.     dc.b    27,"[1m",'SubSong routine called.',27,"[0m",10
  529.     dc.b    'This routine must determine the min & max subsong number.',10
  530.     dc.b    10,0
  531.  
  532. InfoTxt10
  533.     dc.b    27,"[1m",'Volume routine called.',27,"[0m",10
  534.     dc.b    'This routine controls the volume.',10
  535.     dc.b    10,0
  536.  
  537. InfoTxt11
  538.     dc.b    27,"[1m",'Balance routine called.',27,"[0m",10
  539.     dc.b    'This routine controls the balance.',10
  540.     dc.b    10,0
  541.  
  542.  
  543. *-----------------------------------------------------------------------*
  544.  
  545.  
  546.     END
  547.